<?php
  class Model_train extends CI_Model{
	  protected $_table = "tbl_trains";
	  protected $_plan = "tbl_news";
	  protected $_service = "tbl_services";
	  protected $_order = "tbl_order_train";
	  public function __construct(){
		  parent::__construct();
		  $this->load->database();
	  }
	  public function getdata($id){
		  $this->db->where("train_rewrite",$id);
		  return $this->db->get($this->_table)->row_array();
	  }
	  public function listservice($trainid){
		  $this->db->where("train_id",$trainid);
		  return $this->db->get($this->_service)->result_array();
	  }
	  public function listtrains($limit){
		  $this->db->limit($limit);
		  $this->db->order_by("train_order","ASC");
		  return $this->db->get($this->_table)->result_array();
	  }
	  public function plantrip($limit){
		  $this->db->limit($limit);
		  return $this->db->get($this->_plan)->result_array();
	  }
	  public function addorder($data){
		  $this->db->insert($this->_order,$data);
		  
	  }
  }